Component({
    data: {
      currentPath: '',
      list: [
        {
          pagePath: '/pages/index/index',
          text: '首页',
          iconPath: '/assets/icom/首页.png',
          selectedIconPath: '/assets/icom/首页1.png'
        },
        
        {
          pagePath: '/pages/Buyflowers/Buyflowers',
          text: '买花',
          iconPath: '/assets/icom/开花.png',
          selectedIconPath: '/assets/icom/开花1.png'
        },
        {
            pagePath: '/pages/friends/friends',
            text: '花友圈',
            iconPath: '/assets/icom/爱心.png',
            selectedIconPath: '/assets/icom/爱心.png'
          },
        {
          pagePath: '/pages/shopping/shopping',
          text: '购物车',
          iconPath: '/assets/icom/购物袋.png',
          selectedIconPath: '/assets/icom/购物袋1.png'
        },
        {
          pagePath: '/pages/mine/mine',
          text: '我的',
          iconPath: '/assets/icom/人员.png',
          selectedIconPath: '/assets/icom/人员1.png'
        }
      ]
    },
    lifetimes: {
        attached() {
          // 获取当前页面路径
          const pages = getCurrentPages();
          if (pages.length > 0) {
            const currentPage = pages[pages.length - 1];
            this.setData({
              currentPath: `/${currentPage.route}`
            });
          }
        }
      },
    methods: {
      switchTab(e) {
        const path = e.currentTarget.dataset.path;
        wx.navigateTo({
          url: path
        });
        this.setData({
          currentPath: path
        });
      }
    }
  });